<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use InboundService;
use Log;

/**
 * 从总部获取入库详情信息到采购系统
 */
class InboundDetailJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $timeout = 280;        //队列超时时间
    public $failOnTimeout = true; //作业超时将其标记为失败
    protected $scm_conn;          //采购系统连接
    protected $remote_conn;       //总部连接
    public $tries = 1;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($params=null)
    {
        $this->scm_conn = $params && isset($params['scm_conn']) ? $params['scm_conn'] : '';
        $this->remote_conn = $params && isset($params['remote_conn']) ? $params['remote_conn'] : '';
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        InboundService::syncInboundDetail($this->scm_conn, $this->remote_conn);
    }
}
